﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace Model
{
   public class UserListViewEntity
    {
        public int Id { get; set; }
        public string UserAccount { get; set; }
        public string UserName { get; set; }
        public string Description { get; set; }
        public string FactoryCode { get; set; }
        public string Title { get; set; }
        public bool IsActive { get; set; }

        public UserListViewEntity() { }
        public UserListViewEntity(DataRow row)
        {
            Id = int.Parse(row["Id"].ToString());
            RoleId = int.Parse(row["RoleId"].ToString());
            UserAccount = row["UserAccount"].ToString();
            UserName = row["UserName"].ToString();
            Description = GetXml(row["Description"].ToString());
            FactoryCode = row["FactoryCode"].ToString();
            Title = row["Title"].ToString();
            IsActive = bool.Parse(row["IsActive"].ToString());
        }
       
        public int RoleId { get; set; }

        public string GetXml(string xml)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xml);
            XmlNodeList nodes = xmlDoc.SelectNodes(@"/items/item");
             string description=string.Empty;
            foreach (XmlNode node in nodes)
            {
                //通过Attributes获得属性名字为culture的属性
                description = node.Attributes["value"].Value;
            }
            return description;
        }
    }
}
